import request from '@/axios';
import {baseUrl} from '@/config/env';


export const list = (data) => {
    return request({
            url: baseUrl + '/start/actForm/page',
            method: 'get',
            params: data
        }
    )
}
export const add = (data) => {
    return request({
            url: baseUrl + '/start/actForm/add',
            method: 'post',
            data: data
        }
    )
}

export const getById = (id) => {
    return request({
            url: baseUrl + '/start/actForm/getById/' + id,
            method: 'get',
        }
    )
}

export const updateById = (data) => {
    return request({
            url: baseUrl + '/start/actForm/updateById',
            method: 'put',
            data: data
        }
    )
}

export const deleteById = (id) => {
    return request({
            url: baseUrl + '/start/actForm/deleteById/' + id,
            method: 'delete',
        }
    )
}

export const getByTableId = (tableId) => {
    return request({
            url: baseUrl + '/start/actForm/getByTableId/' + tableId,
            method: 'get',
        }
    )
}
export const createMenu = (tableId, data) => {
    return request({
            url: baseUrl + '/start/actForm/createMenu/' + tableId,
            method: 'get',
            params: data,
        }
    )
}
export const getTableOption = (tableId) => {
    return request({
            url: baseUrl + '/start/actForm/getTableOption/' + tableId,
            method: 'get',
        }
    )
}


export const saveTableOption = (tableId, data) => {
    return request({
            url: baseUrl + '/sysFormConfig/saveTableOption/' + tableId,
            method: 'post',
            data: data,
        }
    )
}

export const synchronizationTable = (tableId) => {
    return request({
            url: `${baseUrl}/start/actForm/synchronizationTable/${tableId}/` + 5,
            method: 'get',

        }
    )
}
export const getAllStorage = () => {
    return request({
            url: `${baseUrl}/start/actForm/getAllStorage`,
            method: 'get',
        }
    )
}
export const saveOrUpdate = (data) => {
    if (data.id) {
        return updateById(data);
    }
    return add(data)
}
const actFormApi = {
    list,
    add,
    getById,
    updateById,
    saveOrUpdate,
    deleteById,
    getByTableId,
    createMenu,
    getTableOption,
    saveTableOption,
    synchronizationTable,
    getAllStorage,
}
export default actFormApi
